<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div class="modal-dialog ms-modal-dialog" style = "width:800px; margin-top:100px; font-size: .6rem;">
  <div class="modal-content">

    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      <h4 class="modal-title">修改公司基本信息</h4>
    </div>
      
    <form class="form-horizontal ms-form modal-search-form" role="form" method="POST" action="${ctx.host}/suppliers/${supplier.id}/supplier-info" data-validate="true">
    
      <input type="hidden" name="_method" value="PATCH" />
      <input type="hidden" name="supplierId" value="${supplier.id}" />
      <input type="hidden" name="supplierInfoId" value="${supplierInfo.id}" />
      
      <div class="modal-body">
         
        <div class="form-horizontal ms-form form-personal-info">
    
          <div class="form-group ms-form-group">
            <label class="control-label col-xs-3 ">1&nbsp;<span class="color-red">*</span>公司代码：</label>
            <div class="col-xs-3 pull-left">
              <p class="form-control-static" style="font-size: 12px; font-weight: bold;">${supplier.code}</p>
            </div>
            <c:choose>
              <c:when test="${supplier.status.description eq '合格'}">
                <label class="control-label col-xs-3 ">2&nbsp;<span class="color-red">*</span>运输公司现用名(全称)：</label>
                <p class="form-control-static" style="font-size: 10px;">${supplier.name}</p>
              </c:when>
              <c:otherwise>
                <label class="control-label col-xs-3 ">2&nbsp;<span class="color-red">*</span>运输公司现用名(全称)：</label>
                  <div class="col-xs-3 pull-left">
                  <input type="text" name="name" class="form-control" value="${supplier.name}" placeholder="" data-validate="required" tabindex="1" autocomplete="off"/>
                </div>
              </c:otherwise>
            </c:choose>
            
          </div>
          
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">3.1&nbsp;运输公司曾用名I(全称)：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="formerName" class="form-control" value="${supplierInfo.formerName}" placeholder="" tabindex="1" autocomplete="off"/>
            </div>
            
            <label class="control-label col-xs-3">3.2&nbsp;运输公司曾用名II(全称)：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="secondFormerName" class="form-control" value="${supplierInfo.secondFormerName}" placeholder="" tabindex="1" autocomplete="off"/>
            </div>
         </div>
  
         <div class="form-group  ms-form-group">
           <label class="control-label col-xs-3">4&nbsp;<span class="color-red">*</span>董事长：</label>
           <div class="col-xs-3 pull-left">
             <input type="text" name="chairman" class="form-control" value="${supplierInfo.chairman}" placeholder="" data-validate="required" tabindex="1" autocomplete="off"/>
           </div>
           
           <label class="control-label col-xs-3">5&nbsp;<span class="color-red">*</span>总经理：</label>
	         <div class="col-xs-3 pull-left">
	           <input type="text" name="manager" class="form-control" value="${supplierInfo.manager}" placeholder="" data-validate="required" tabindex="1" autocomplete="off"/>
	         </div>
         </div>
        
          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">6&nbsp;<span class="color-red">*</span>总经理联系电话：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="managerPhone" class="form-control" value="${supplierInfo.managerPhone}" placeholder="" data-validate="required" tabindex="1" autocomplete="off" data-validate="required/mobile"/>
            </div>
            
            <label class="control-label col-xs-3">7.1&nbsp;<span class="color-red">*</span>总经理Email&nbsp;I：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="managerEmail" class="form-control" value="${supplierInfo.managerEmail}" placeholder="" data-validate="required" tabindex="1" autocomplete="off"/>
            </div>
          </div>

          <div class="form-group  ms-form-group">
            <label class="control-label col-xs-3">7.2&nbsp;总经理Email&nbsp;II：</label>
            <div class="col-xs-3 pull-left">
              <input type="text" name="secondManagerEmail" class="form-control" value="${supplierInfo.secondManagerEmail}" placeholder="" tabindex="1" autocomplete="off"/>
            </div>
            
            <label class="control-label col-xs-3">8&nbsp;<span class="color-red">*</span>公司性质：</label>
            <div class="col-xs-3 pull-left">
              <select class="select2 form-control" name="companyProperty"  data-validate="required" tabindex="1">
                <option></option>
                <c:forEach var="companyProperty" items="${enums['CompanyProperty']}">
                  <option value="${companyProperty.code}" ${companyProperty.code eq supplierInfo.companyProperty ? 'selected' : ''}>${companyProperty.description}</option>
                </c:forEach>
              </select>
            </div>
          </div>
  
           <div class="form-group  ms-form-group">
             <label class="control-label col-xs-3">9&nbsp;<span class="color-red">*</span>成立年月：</label>
             <div class="col-xs-3 pull-left">
               <input type="text" name="yearFounded" data-validate="required" class="form-control year-month" value="<fmt:formatDate value="${supplierInfo.yearFounded}" pattern="yyyy-MM"/>" placeholder="" tabindex="1" autocomplete="off"/>
             </div>
             
             <label class="control-label col-xs-3">10&nbsp;<span class="color-red">*</span>注册地：</label>
             <div class="col-xs-3 pull-left">
               <input type="text" name="registerAddress" class="form-control" value="${supplierInfo.registerAddress}" data-validate="required" placeholder="" tabindex="1" autocomplete="off"/>
             </div>
           </div>
  
            <div class="form-group  ms-form-group">
              <label class="control-label col-xs-3">11&nbsp;<span class="color-red">*</span>注册资金(万元)：</label>
              <div class="col-xs-3 pull-left">
               <input type="text" name="registerCapital" class="form-control" value="${supplierInfo.registerCapital}" data-validate="required|number" placeholder="" tabindex="1" autocomplete="off"/>
              </div>
              
              <label class="control-label col-xs-3">12&nbsp;<span class="color-red">*</span>联系地址：</label>
              <div class="col-xs-3 pull-left">
                <input type="text" name="contactAddress" class="form-control" value="${supplierInfo.contactAddress}" placeholder="" data-validate="required" tabindex="1" autocomplete="off"/>
              </div>
            </div>
            
            <div class="form-group  ms-form-group">
              <label class="control-label col-xs-3">14.2&nbsp;<span class="color-red">*</span>体系标准文件类型：</label>
              <div class="col-xs-3 pull-left">
                <select name="standardDocument" data-validate="required" multiple class="select2 multiple form-control">
                  <option></option>
                  <c:forEach var="standardDocument" items="${enums['StandardDocument']}">
                    <option value="${standardDocument.code}" ${supplierInfo.standardDocument.contains(standardDocument.code) ? 'selected' : ''}>${standardDocument.description}</option>
                  </c:forEach>
                </select>
              </div>

              <label class="control-label col-xs-3">14.3&nbsp;<span class="color-red">*</span>统一社会信用代码：</label>
              <div class="col-xs-3 pull-left">
                <input type="text" name="uniformSocialCreditCode" class="form-control" value="${supplierInfo.uniformSocialCreditCode}" placeholder="" data-validate="required" tabindex="1" autocomplete="off"/>
              </div>
            </div>
            
<%--             <div class="form-group  ms-form-group">
              <label class="control-label col-xs-3">13.2&nbsp;<span class="color-red standard-document-date">*</span>体系文件有效期：</label>
              <div class="col-xs-3 pull-left">
                <input type="text" name="standardDocumentDate" class="form-control date" value="<fmt:formatDate value="${supplierInfo.standardDocumentDate}" pattern="yyyy-MM-dd"/>" autocomplete="off"/>
              </div>
            </div> --%>
            
         </div>
      </div>
      
      <div class="modal-footer ms-modal-footer">
        <button type="submit" class="btn ms-btn btn-primary">确定</button>
        <button type="button" class="btn ms-btn ms-btn-gary" data-dismiss="modal">取消</button>
      </div>
      
    </form>
      
  </div>
</div>

<script type="text/javascript">
    $(document).ready(function () {

        $('select[name="companyProperty"]').select2({
          theme: "classic",
          placeholder: '请选择',
          minimumResultsForSearch: -1,
          allowClear: true
        });

        $('select[name="standardDocument"]').select2({
          theme: "classic",
          placeholder: '请选择',
          minimumResultsForSearch: -1,
          allowClear: true
        });

        $('.year-month').datetimepicker({
          format: 'yyyy-mm',
          autoclose: true,
          language: 'zh-CN',
          todayBtn: true,
          startView: 'year',
          minView:'year',
          maxView:'decade'
        });
        
        $('.date').datetimepicker({
          format: 'yyyy-mm-dd',
          autoclose: true,
          language: 'zh-CN',
          todayBtn: 'linked',
          startDate: '${today}',
          todayHighlight: true,
          pickerPosition: 'bottom-right',
          minView: 'month'
        });

        $(document).on('change', 'select[name="standardDocument"]', function(e) {
          var standardDocument = $('select[name="standardDocument"]').val();
          if (standardDocument != '01') {
            $('span.standard-document-date').show();
            $('input[name="standardDocumentDate"]').attr('data-validate', 'required');
            $('form[data-validate="true"]').bt_validate()
          } else {
            $('span.standard-document-date').hide();
            $('input[name="standardDocumentDate"]').removeAttr('data-validate');
            $('form[data-validate="true"]').bt_validate()
          }
        });

    })
</script>
